# -*- python -*-
# ex: set syntax=python:
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# See master.experimental/slaves.cfg for documentation.


def linux():
  """Linux VMs can hold a maximum of 4 checkouts per slave."""
  perf_bisect_builders = [26, 27, 28, 29]
  perf_a4_slaves = [11, 12]
  perf_bisector_slaves = [74]
  perf_tester_slaves = [75]

  result = []

  # Perf bisect slaves
  result.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'linux',
      'version': 'precise',
      'bits': '64',
      'builder': 'linux_perf_bisect_builder',
      'hostname': 'build%d-m4' % i,
    } for i in perf_bisect_builders
  )

  result.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'linux',
      'version': 'precise',
      'bits': '64',
      'builder': 'linux_perf_bisect',
      'hostname': 'build%d-a4' % i,
    } for i in perf_a4_slaves
  )

  result.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'linux',
      'version': 'precise',
      'bits': '64',
      'builder': 'linux_perf_bisector',
      'hostname': 'build%d-m4' % i,
    } for i in perf_bisector_slaves
  )

  result.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'linux',
      'version': 'precise',
      'bits': '64',
      'builder': 'linux_perf_tester',
      'hostname': 'build%d-m4' % i,
    } for i in perf_tester_slaves
  )

  return result


def mac():
  perf_bisect_builders = [82, 83, 84 ,85]
  perf_bisect_10_8_slaves = [201, 202, 203]
  perf_bisect_10_9_slaves = [195]

  out = []

  out.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'mac',
      'version': '10.8',
      'bits': '64',
      'builder': 'mac_perf_bisect_builder',
      'hostname': 'vm%d-a4' % i,
    } for i in perf_bisect_builders
  )

  out.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'mac',
      'version': '10.8',
      'bits': '64',
      'builder': 'mac_perf_bisect',
      'hostname': 'build%d-a4' % i,
    } for i in perf_bisect_10_8_slaves
  )

  out.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'mac',
      'version': '10.9',
      'bits': '64',
      'builder': 'mac_10_9_perf_bisect',
      'hostname': 'build%d-a4' % i,
    } for i in perf_bisect_10_9_slaves
  )

  return out


def android():
  perf_bisect_builders = [
    {
      'master': 'ChromiumPerfTryServer',
      'builder': 'android_perf_bisect_builder',
      'hostname': 'slave%d-c4' % i,
      'os': 'linux',
      'version': 'precise',
      'bits': '64'
    } for i in [726, 727, 728, 729]
  ]

  perf_arm64_bisect_builders = [
    {
      'master': 'ChromiumPerfTryServer',
      'builder': 'android_arm64_perf_bisect_builder',
      'hostname': 'slave%d-c4' % i,
      'os': 'linux',
      'version': 'precise',
      'bits': '64'
    } for i in [423, 424]
  ]

  bisect_slaves_list = {
    'motoe': ['build76-a4'],
    'one': ['build219-a4', 'build220-a4', 'build221-a4'],
    'nexus4': ['build6-a4', 'build205-a4', 'build206-a4'],
    'nexus5': ['build27-a4', 'build207-a4', 'build208-a4'],
    'nexus6': ['build216-a4', 'build217-a4', 'build218-a4'],
    'nexus7': ['build7-a4', 'build209-a4', 'build210-a4'],
    'nexus9': ['build213-a4', 'build214-a4', 'build215-a4'],
    'nexus10': ['build8-a4', 'build211-a4', 'build212-a4']
  }

  perf_bisect_slaves = []

  for device, hosts in bisect_slaves_list.iteritems():
    for host in hosts:
      perf_bisect_slaves.append(
        {
          'master': 'ChromiumPerfTryServer',
          'builder': 'android_%s_perf_bisect' % device,
          'hostname': host,
          'os': 'linux',
          'version': 'precise',
          'bits': '64'
        }
      )

  return perf_bisect_builders + perf_arm64_bisect_builders + perf_bisect_slaves


def windows():
  perf_bisect_builder_ids = [36, 37, 38, 39]
  perf_bisect_x64_builders = [40, 41, 42, 43]
  perf_bisect_slave_ids = [82]
  perf_a4_slaves = [2, 3]
  perf_xp_slaves = [79]
  perf_8_a4_slaves = [1]
  perf_win_x64_m4_slaves = [18]
  perf_win_x64_ati_gpu_slaves = [102, 103, 104]
  perf_win_x64_nvidia_gpu_slaves= [96, 97, 98]
  # Bisect slaves
  perf_bisect_builders = [
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '32',
      'builder': 'win_perf_bisect_builder',
      'hostname': 'build%d-m4' % i,
    } for i in perf_bisect_builder_ids
  ]

  perf_bisect_builders.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '64',
      'builder': 'win_x64_perf_bisect_builder',
      'hostname': 'build%d-m4' % i,
    } for i in perf_bisect_x64_builders
  )

  perf_bisect_slaves = [
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '64',
      'builder': 'win_perf_bisect',
      'hostname': 'chromeperf%d' % i,
    } for i in perf_bisect_slave_ids
  ]

  perf_bisect_slaves.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '64',
      'builder': 'win_perf_bisect',
      'hostname': 'build%d-a4' % i,
    } for i in perf_a4_slaves
  )

  perf_bisect_slaves.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'xp',
      'bits': '32',
      'builder': 'win_xp_perf_bisect',
      'hostname': 'chromeperf%d' % i,
    } for i in perf_xp_slaves
  )

  perf_bisect_slaves.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win8',
      'bits': '64',
      'builder': 'win_8_perf_bisect',
      'hostname': 'build%d-a4' % i,
    } for i in perf_8_a4_slaves
  )

  perf_bisect_slaves.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '64',
      'builder': 'win_x64_perf_bisect',
      'hostname': 'build%d-m4' % i,
    } for i in perf_win_x64_m4_slaves
  )

  perf_bisect_slaves.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '64',
      'builder': 'win_x64_ati_gpu_perf_bisect',
      'hostname': 'build%d-m4' % i,
    } for i in perf_win_x64_ati_gpu_slaves
  )

  perf_bisect_slaves.extend(
    {
      'master': 'ChromiumPerfTryServer',
      'os': 'win',
      'version': 'win7',
      'bits': '64',
      'builder': 'win_x64_nvidia_gpu_perf_bisect',
      'hostname': 'build%d-m4' % i,
    } for i in perf_win_x64_nvidia_gpu_slaves
  )

  return (
      perf_bisect_slaves +
      perf_bisect_builders)


slaves = linux() + mac() + windows() + android()
